package com.drinks.yiniang.adapter.shop;

import android.content.Context;
import android.support.annotation.Nullable;

import com.chad.library.adapter.base.BaseViewHolder;
import com.drinks.yiniang.R;
import com.drinks.yiniang.adapter.base.BaseQuickRCVAdapter;
import com.drinks.yiniang.entity.shop.ShopJson;
import com.drinks.yiniang.utils.GlideUtils;
import com.hansen.library.ui.widget.image.RatioRoundImageView;
import com.hansen.library.utils.StringUtils;

import java.util.List;

/**
 * 店铺列表adapter
 * @author han
 * @date 2019/8/30
 */
public class ShopListAdapter extends BaseQuickRCVAdapter<ShopJson.ShopList, BaseViewHolder> {

    private StringBuilder builder;

    public ShopListAdapter(Context mContext, @Nullable List<ShopJson.ShopList> data) {
        super(R.layout.item_shop_list, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, ShopJson.ShopList item) {
        GlideUtils.loaShopList(mContext, (RatioRoundImageView) helper.getView(R.id.iv_shop_list_cover), item.getCover_url());

        //地址
        builder = new StringBuilder();
        builder.append(mContext.getString(R.string.text_address_colon));
        builder.append(StringUtils.getNullEmptyConvert__(item.getAddress()));
        helper.setText(R.id.tv_shop_list_address, builder);

        //电话
        builder = new StringBuilder();
        builder.append(mContext.getString(R.string.text_tel_colon));
        builder.append(StringUtils.getNullEmptyConvert__(item.getMobile()));
        helper.setText(R.id.tv_shop_list_phone, builder);

        //位置
        helper.setText(R.id.tv_shop_list_distance, StringUtils.getNullEmptyConvert__(item.getDistance()));
    }
}
